import turtle as t
t.penup()
t.goto(250, -200)
t.shape('turtle')
# 设置窗口大小
t.setup(500, 600)
t.bgpic('雪地迷宫.png')


# 创建画笔1
p1 = t.Pen()
p1.shape('turtle')
p1.color('red')
p1.pensize(2)
p1.setheading(-90)
p1.penup()
p1.goto(-230, 220)
p1.pendown()

# 画笔1前进指令
def up1():
    p1.forward(10)
    if p1.xcor() == 250 and p1.ycor() == -200:
        p1.hideturtle()
        p1.write('海龟1获胜！', align='center', font=('微软雅黑', 16, 'bold'))

def left1():
    p1.left(90)

def right1():
    p1.right(90)

def gohome1():
    p1.clear()
    p1.setheading(-90)
    p1.penup()
    p1.goto(-230, 220)
    p1.pendown()


# 画笔1键盘事件
t.onkey(up1, "w")
t.onkey(left1, "a")
t.onkey(right1, "d")
t.onkey(gohome1, "s")


#事件监听
t.listen()

t.done()
